package com.demo.shardingsphere.order.mapper;

import com.demo.shardingsphere.order.model.Order;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;


@Mapper
public interface OrderMapper {

    @Insert({"insert into t_order (`order_no`, `member_id`, `supplier_id`, `create_time`) values (#{order.orderNo}, #{order.memberId}, #{order.supplierId}, #{order.createTime} )"})
    int insertOrder(@Param("order") Order order);


    @Select("select order_no as orderNo, member_id as memberId, supplier_id as supplierId , create_time createTime from t_order where member_id  = #{memberId}")
    List<Order> queryOrderListByUserId(Long userId);


    @Select("select order_no as orderNo, member_id as memberId, supplier_id as supplierId , create_time createTime from t_order_no where order_no  = #{orderNo}")
    Order queryByOrderNo(@Param("orderNo") String orderNo);
}
